package qlsl.androiddesign.adapter.commonadapter;

import java.io.File;
import java.util.List;

import com.qlsl.androiddesign.kuaiwa.R;

import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import qlsl.androiddesign.activity.baseactivity.BaseActivity;
import qlsl.androiddesign.adapter.baseadapter.BaseAdapter;
import qlsl.androiddesign.util.commonutil.ImageUtils;

/**
 * 公用图片添加适配器<br/>
 *
 */
public class PictureAddAdapter extends BaseAdapter<File> {

	public PictureAddAdapter(BaseActivity activity, List<File> list) {
		super(activity, list);
	}

	public View getView(int position, View convertView, ViewGroup parent) {
		convertView = getItemView(convertView, R.layout.griditem_photo_add);

		ImageView iv_icon = getView(convertView, R.id.iv_icon);
		ImageView iv_delete = getView(convertView, R.id.iv_delete);
		TextView tv_add = getView(convertView, R.id.tv_add);

		File file = getItem(position);

		ImageUtils.rect(activity, file, iv_icon);

		if (position != getCount() - 1) {
			iv_icon.setVisibility(View.VISIBLE);
			iv_delete.setVisibility(View.VISIBLE);
			tv_add.setVisibility(View.GONE);
		} else {
			iv_icon.setVisibility(View.GONE);
			iv_delete.setVisibility(View.GONE);
			tv_add.setVisibility(View.VISIBLE);
		}

		return convertView;
	}
}
